﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Microsoft.Practices.EnterpriseLibrary.Data.Sql;

namespace QLNHK.BLL
{
    public partial class BaoCao
    {
        public static DataSet DanhSachNhanKhauTheoGioiTinh(int tinhTP, int quanHuyen, int xaPhuong, int toDanPho)
        {
            const string spName = "p_BaoCao_DanhSachNhanKhauTheoGioiTinh";
            SqlDatabase db = (SqlDatabase)DatabaseFactory.CreateDatabase();
            SqlCommand dbCommand = (SqlCommand)db.GetStoredProcCommand(spName);

            db.AddInParameter(dbCommand, "@TinhTPID", SqlDbType.Int, tinhTP);
            db.AddInParameter(dbCommand, "@QuanHuyenID", SqlDbType.Int, quanHuyen);
            db.AddInParameter(dbCommand, "@XaPhuongID", SqlDbType.Int, xaPhuong);
            db.AddInParameter(dbCommand, "@ToDanPhoID", SqlDbType.Int, toDanPho);

            return db.ExecuteDataSet(dbCommand);
        }
        public static DataSet DanhSachChuaLamCMND(int tinhTP, int quanHuyen, int xaPhuong, int toDanPho)
        {
            const string spName = "p_BaoCao_DanhSachChuaLamCMND";
            SqlDatabase db = (SqlDatabase)DatabaseFactory.CreateDatabase();
            SqlCommand dbCommand = (SqlCommand)db.GetStoredProcCommand(spName);

            db.AddInParameter(dbCommand, "@TinhTPID", SqlDbType.Int, tinhTP);
            db.AddInParameter(dbCommand, "@QuanHuyenID", SqlDbType.Int, quanHuyen);
            db.AddInParameter(dbCommand, "@XaPhuongID", SqlDbType.Int, xaPhuong);
            db.AddInParameter(dbCommand, "@ToDanPhoID", SqlDbType.Int, toDanPho);

            return db.ExecuteDataSet(dbCommand);
        }
        public static DataSet DanhSachNVQS(int tinhTP, int quanHuyen, int xaPhuong, int toDanPho)
        {
            const string spName = "p_BaoCao_DanhSachNVQS";
            SqlDatabase db = (SqlDatabase)DatabaseFactory.CreateDatabase();
            SqlCommand dbCommand = (SqlCommand)db.GetStoredProcCommand(spName);

            db.AddInParameter(dbCommand, "@TinhTPID", SqlDbType.Int, tinhTP);
            db.AddInParameter(dbCommand, "@QuanHuyenID", SqlDbType.Int, quanHuyen);
            db.AddInParameter(dbCommand, "@XaPhuongID", SqlDbType.Int, xaPhuong);
            db.AddInParameter(dbCommand, "@ToDanPhoID", SqlDbType.Int, toDanPho);

            return db.ExecuteDataSet(dbCommand);
        }
        public static DataSet DanhSachNhanKhauTheoDoTuoi(int tuTuoi, int denTuoi, int tinhTP, int quanHuyen, int xaPhuong, int toDanPho)
        {
            const string spName = "p_BaoCao_DanhSachNhanKhauTheoDoTuoi";
            SqlDatabase db = (SqlDatabase)DatabaseFactory.CreateDatabase();
            SqlCommand dbCommand = (SqlCommand)db.GetStoredProcCommand(spName);

            db.AddInParameter(dbCommand, "@TuTuoi", SqlDbType.Int, tuTuoi);
            db.AddInParameter(dbCommand, "@DenTuoi", SqlDbType.Int, denTuoi);
            db.AddInParameter(dbCommand, "@TinhTPID", SqlDbType.Int, tinhTP);
            db.AddInParameter(dbCommand, "@QuanHuyenID", SqlDbType.Int, quanHuyen);
            db.AddInParameter(dbCommand, "@XaPhuongID", SqlDbType.Int, xaPhuong);
            db.AddInParameter(dbCommand, "@ToDanPhoID", SqlDbType.Int, toDanPho);

            return db.ExecuteDataSet(dbCommand);
        }
        public static DataSet DanhSachTongSoNhanKhauQuanPhuong(int tinhTP, int quanHuyen, int xaPhuong)
        {
            const string spName = "p_BaoCao_TongSoNhanKhauQuanPhuong";
            SqlDatabase db = (SqlDatabase)DatabaseFactory.CreateDatabase();
            SqlCommand dbCommand = (SqlCommand)db.GetStoredProcCommand(spName);

            db.AddInParameter(dbCommand, "@TinhTPID", SqlDbType.Int, tinhTP);
            db.AddInParameter(dbCommand, "@QuanHuyenID", SqlDbType.Int, quanHuyen);
            db.AddInParameter(dbCommand, "@XaPhuongID", SqlDbType.Int, xaPhuong);

            return db.ExecuteDataSet(dbCommand);
        }
        public static DataSet DanhSachTongSoHoKhau(int tinhTP, int quanHuyen, int xaPhuong)
        {
            const string spName = "p_BaoCao_TongSoHoKhau";
            SqlDatabase db = (SqlDatabase)DatabaseFactory.CreateDatabase();
            SqlCommand dbCommand = (SqlCommand)db.GetStoredProcCommand(spName);

            db.AddInParameter(dbCommand, "@TinhTPID", SqlDbType.Int, tinhTP);
            db.AddInParameter(dbCommand, "@QuanHuyenID", SqlDbType.Int, quanHuyen);
            db.AddInParameter(dbCommand, "@XaPhuongID", SqlDbType.Int, xaPhuong);

            return db.ExecuteDataSet(dbCommand);
        }
        public static DataSet DanhSachNhanKhauTheoDanTocTonGiao(int danToc, int tonGiao, int tinhTP, int quanHuyen, int xaPhuong, int toDanPho)
        {
            const string spName = "p_BaoCao_DanhSachNhanKhauTheoDanTocTonGiao";
            SqlDatabase db = (SqlDatabase)DatabaseFactory.CreateDatabase();
            SqlCommand dbCommand = (SqlCommand)db.GetStoredProcCommand(spName);

            db.AddInParameter(dbCommand, "@DanTocID", SqlDbType.Int, danToc);
            db.AddInParameter(dbCommand, "@TonGiaoID", SqlDbType.Int, tonGiao);
            db.AddInParameter(dbCommand, "@TinhTPID", SqlDbType.Int, tinhTP);
            db.AddInParameter(dbCommand, "@QuanHuyenID", SqlDbType.Int, quanHuyen);
            db.AddInParameter(dbCommand, "@XaPhuongID", SqlDbType.Int, xaPhuong);
            db.AddInParameter(dbCommand, "@ToDanPhoID", SqlDbType.Int, toDanPho);

            return db.ExecuteDataSet(dbCommand);
        }
        public static DataSet DanhSachNhanKhauChuyenDiNoiKhac(DateTime tuNgay, DateTime denNgay, int tinhTP, int quanHuyen, int xaPhuong, int toDanPho)
        {
            const string spName = "p_BaoCao_DanhSachNhanKhauChuyenDiNoiKhac";
            SqlDatabase db = (SqlDatabase)DatabaseFactory.CreateDatabase();
            SqlCommand dbCommand = (SqlCommand)db.GetStoredProcCommand(spName);

            db.AddInParameter(dbCommand, "@TuNgay", SqlDbType.DateTime, tuNgay);
            db.AddInParameter(dbCommand, "@DenNgay", SqlDbType.DateTime, denNgay);
            db.AddInParameter(dbCommand, "@TinhTPID", SqlDbType.Int, tinhTP);
            db.AddInParameter(dbCommand, "@QuanHuyenID", SqlDbType.Int, quanHuyen);
            db.AddInParameter(dbCommand, "@XaPhuongID", SqlDbType.Int, xaPhuong);
            db.AddInParameter(dbCommand, "@ToDanPhoID", SqlDbType.Int, toDanPho);

            return db.ExecuteDataSet(dbCommand);
        }
        public static DataSet DanhSachTongSoNhanKhauChuyenDen(DateTime tuNgay, DateTime denNgay, int tinhTP, int quanHuyen, int xaPhuong)
        {
            const string spName = "p_BaoCao_TongSoNhanKhauChuyenDen";
            SqlDatabase db = (SqlDatabase)DatabaseFactory.CreateDatabase();
            SqlCommand dbCommand = (SqlCommand)db.GetStoredProcCommand(spName);

            db.AddInParameter(dbCommand, "@TuNgay", SqlDbType.DateTime, tuNgay);
            db.AddInParameter(dbCommand, "@DenNgay", SqlDbType.DateTime, denNgay);
            db.AddInParameter(dbCommand, "@TinhTPID", SqlDbType.Int, tinhTP);
            db.AddInParameter(dbCommand, "@QuanHuyenID", SqlDbType.Int, quanHuyen);
            db.AddInParameter(dbCommand, "@XaPhuongID", SqlDbType.Int, xaPhuong);

            return db.ExecuteDataSet(dbCommand);
        }

        public static DataSet BaoCaoTongHop(int tinhTP, int quanHuyen, int xaPhuong)
        {
            const string spName = "p_BaoCao_TongHop";
            SqlDatabase db = (SqlDatabase)DatabaseFactory.CreateDatabase();
            SqlCommand dbCommand = (SqlCommand)db.GetStoredProcCommand(spName);

            db.AddInParameter(dbCommand, "@TinhTPID", SqlDbType.Int, tinhTP);
            db.AddInParameter(dbCommand, "@QuanHuyenID", SqlDbType.Int, quanHuyen);
            db.AddInParameter(dbCommand, "@XaPhuongID", SqlDbType.Int, xaPhuong);

            return db.ExecuteDataSet(dbCommand);
        }
    }
}